#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "OLED.h"
#include "Serial.h"

uint8_t arr1[] = {0x01, 0x02, 0x03, 0x04, 0x05};
uint8_t RxData = 0;

int main(void)
{

	OLED_Init();
	Serial_Init();
	OLED_ShowString(1, 1, "Hello Bird!");
	OLED_ShowString(2, 1, "RX:");
	//Serial_SendArray(arr1, 5);
	//Serial_SendString("Hello Wang Yi Ming!");
	//Serial_SendNum(12345, 5);
	//printf("Wang's Age = %d\n", 20);
	//Serial_Printf("王一鸣我爱你\r\n");
	while (1)
	{
		//自制串口接收
		//当有数据被接收时，会自动硬件置1
		//对DR进行读操作会 自动 置零 不需要清除标志位
		if (Serial_GetRxFlag() == 1)
		{
			RxData = Serial_GetRxData();
			Serial_SendByte(RxData);
			OLED_ShowHexNum(2, 4, RxData, 2);
		}

		OLED_ShowString(3, 1, "Running");
		Delay_ms(100);
		OLED_ShowString(3, 1, "       ");
		Delay_ms(100);
		__WFI();									//进入中断唤醒睡眠模式
	}

}
